using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataAccess;
using Entity;
using System.Data

namespace Business
{
    public class JobPostingsBusiness
    {
        public DataTable GetJobPostings()
        {
            DataTable dt = new DataTable();
            string sql = "SELECT * FROM JobPostings";
            dt = DA.GetDataTable(sql);
            return dt;
        }

        public int AddJobPostings(JobPostingsEntity jobPostings)
        {
            int i = 0;
            string sql = "INSERT into [dbo].[JobPostings] VALUES (@CompanyID, @JobTitle, @JobDescription, @JobLocation, @JobType, @JobCategory, @JobStatus, @JobPostDate, @JobCloseDate)";
            string[] paras = { "@CompanyID", "@JobTitle", "@JobDescription", "@JobLocation", "@JobType", "@JobCategory", "@JobStatus", "@JobPostDate", "@JobCloseDate" };
            object[] values = { jobPostings.CompanyID, jobPostings.JobTitle, jobPostings.JobDescription, jobPostings.JobLocation, jobPostings.JobType, jobPostings.JobCategory, jobPostings.JobStatus, jobPostings.JobPostDate, jobPostings.JobCloseDate };
            i = DA.ExecuteNonQuery(sql, commandType.Text, parameters, values);
            return i;
        }

        public int UpdateJobPostings(JobPostingsEntity jobPostings)
        {
            int i = 0;
            string sql = "UPDATE [dbo].[JobPostings] SET CompanyID = @CompanyID, JobTitle = @JobTitle, JobDescription = @JobDescription, JobLocation = @JobLocation, JobType = @JobType, JobCategory = @JobCategory, JobStatus = @JobStatus, JobPostDate = @JobPostDate, JobCloseDate = @JobCloseDate WHERE JobPostingID = @JobPostingID";
            string[] paras = { "@CompanyID", "@JobTitle", "@JobDescription", "@JobLocation", "@JobType", "@JobCategory", "@JobStatus", "@JobPostDate", "@JobCloseDate", "@JobPostingID" };
            object[] values = { jobPostings.CompanyID, jobPostings.JobTitle, jobPostings.JobDescription, jobPostings.JobLocation, jobPostings.JobType, jobPostings.JobCategory, jobPostings.JobStatus, jobPostings.JobPostDate, jobPostings.JobCloseDate, jobPostings.JobPostingID };
            i = DA.ExecuteNonQuery(sql, commandType.Text, parameters, values);
            return i;
        }

        public int DeleteJobPostings(int JobPostingID)
        {
            int i = 0;
            string sql = "DELETE FROM [dbo].[JobPostings] WHERE JobPostingID = @JobPostingID";
            string[] paras = { "@JobPostingID" };
            object[] values = { JobPostingID };
            i = DA.ExecuteNonQuery(sql, commandType.Text, parameters, values);
            return i;
        }

        public DataTable GetJobPostings(int JobPostingID)
        {
            DataTable dt = new DataTable();
            string sql = "SELECT * FROM JobPostings WHERE JobPostingID = @JobPostingID";
            string[] paras = { "@JobPostingID" };
            object[] values = { JobPostingID };
            dt = DA.GetDataTable(sql, commandType.Text, parameters, values);
            return dt;
        }
    }
}
